package Project;
//________________________________IMPORTACIONES_________________________________

import java.sql.*;
import javax.swing.*;
//_____________________________CONSTRUCTOR______________________________________

public class BaseDeDatos {
//__________________________________ATRIBUTOS___________________________________

    String sql;
    private static final String url = "jdbc:postgresql://localhost/accidentes";
    private static final String clavePostgres = "root";
    public static Connection con;
    public static Statement stmt;
//___________________________________METODOS____________________________________

    public static void conectarse() {
        try {
            Class.forName("org.postgresql.Driver");
            con = DriverManager.getConnection(url, "postgres", clavePostgres);
            stmt = con.createStatement();
        } catch (ClassNotFoundException | SQLException e) {
            JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
//______________________________________________________________________________

    public static void desconectarse() {
        try {
            stmt.execute("END");
            stmt.close();
            con.close();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
//______________________________________________________________________________